package cn.shotsapp.shots.account.presenter;

import cn.shotsapp.shots.account.contract.LoginContract;
import cn.shotsapp.shots.data.account.repository.IAccountRepository;

/**
 * Created by YZQ on 2016/12/1.
 */

public class LoginPresenter implements LoginContract.Presenter {
    private LoginContract.View mView;
    private IAccountRepository mAccountRepository;

    public LoginPresenter(LoginContract.View mView, IAccountRepository mAccountRepository) {
        this.mView = mView;
        this.mAccountRepository = mAccountRepository;
    }

    @Override
    public void sendRequestCode(String phoneNumber) {
        mAccountRepository.sendSMSCode(phoneNumber, null);
    }

    @Override
    public void checkMatch(String phoneNumber, String SMSCode) {
        // TODO: Handle the verification result of SMS code
        // For example,
        // mAccountRepository.verifyCode(phoneNumber, SMSCode, new SomeListener() {
        //     @Override
        //     void onMatched() {
        //         mAccountRepository.switchAccount(phoneNumber);
        //         mAccountRepository.updateAccount();
        //         mView.switchToStory();
        //     }
        //     @Override
        //     void onMismatched() {
        //     }
        // })
        mAccountRepository.verifyCode(phoneNumber, SMSCode, null);
    }
}
